<?php

class Departement {
	private $idHoraire;
	private $debut;
	private $fin;

	
	//les methodes:
	public function id() { //un getter
		return $this->idHoraire;
	}
	
	public function horaireDebut() { //un getter
		return $this->debut;
	}
	
		public function horaireFin() { //un getter
		return $this->fin;
	}



	
	//Un constructeur
	public function __construct ($debut, $fin) {
		$this->idHoraire = null;
		$this->debut = $debut;
		$this->fin = $fin;

	}
	
	public function create(){
		$debut = $this->debut;
		$fin = $fin->fin;
		
			$req = "INSERT INTO Horaire(debut, fin) VALUES ('$debut, $fin')";
			$res = mysql_query($req) or die ("erreur insertion :  Horaire->create2");
		}

	}
	


	public function delete($idHoraire){
		$req = mysql_query("DELETE FROM Horaire WHERE 
			idHoraire = '$idHoraire'");
		mysql_query($req);
	}

			
	}
	
	public static function getHoraireById($idHoraire) { //une fonction statique
		$req = "SELECT * FROM Horaire WHERE idHoraire='$idHoraire'";
		$res = mysql_query($req) or die ("Horaire-getHoraireById ");
		
		if (mysql_num_rows($res) == 0) //le produit n'existe pas
			return null;
			
		$tuple = mysql_fetch_array($res);
		$Horaire = new Horaire($tuple['nomHoraire']);
		$Horaire->idHoraire = $idHoraire;
	}
}

?>
